/* Create views */

/* Create view with name "Se_alt" */

CREATE VIEW [dbo].[Se_alt] AS SELECT dbo.Kategori.*, dbo.Lager.*, dbo.Product.*, dbo.Stock.*
FROM dbo.Kategori INNER JOIN
dbo.Lager ON dbo.Kategori.id = dbo.Lager.lkatId INNER JOIN
dbo.Product ON dbo.Lager.lvarenr = dbo.Product.varenummer INNER JOIN
dbo.Stock ON dbo.Kategori.id = dbo.Stock.bkatId AND dbo.Product.varenummer = dbo.Stock.bvarenr

/* Create view with name "Sales" */

CREATE VIEW [dbo].[Se_sales]
AS
SELECT        dbo.Kategori.kategori, dbo.Product.varenummer, dbo.Product.beskrivelse, dbo.Stock.antal, dbo.Product.pris
FROM            dbo.Kategori INNER JOIN
                         dbo.Stock ON dbo.Kategori.id = dbo.Stock.bkatId INNER JOIN
                         dbo.Product ON dbo.Stock.bvarenr = dbo.Product.varenummer
						 
						 
/* Create view with name "Lager" */

CREATE VIEW [dbo].[Se_lager]
AS
SELECT        dbo.Product.varenummer, dbo.Product.beskrivelse, dbo.Kategori.kategori, dbo.Lager.raekke, dbo.Lager.hoejde, dbo.Lager.plads, dbo.Stock.antal
FROM            dbo.Product INNER JOIN
                         dbo.Lager ON dbo.Product.varenummer = dbo.Lager.lvarenr INNER JOIN
                         dbo.Kategori ON dbo.Lager.lkatId = dbo.Kategori.id INNER JOIN
                         dbo.Stock ON dbo.Product.varenummer = dbo.Stock.bvarenr AND dbo.Kategori.id = dbo.Stock.bkatId
						 
						 
/* Opretter et view til at vise minimum og stock, samt kategori */
CREATE VIEW [dbo].[Se_stock_min] AS SELECT dbo.Stock.*, dbo.Kategori.kategori
FROM dbo.Stock INNER JOIN dbo.Kategori ON dbo.Stock.bkatId = dbo.Kategori.id